﻿package com.ce.pms.occupation.dao.impl;

import java.util.List;

import org.hibernate.Query;

import com.ce.pms.base.dao.impl.PmsBaseDaoImpl;
import com.ce.pms.occupation.dao.IOccupationChargeItemDao;
import com.ce.pms.occupation.model.OccupationChargeItemDO;

/**
 * 入伙收费项目的DAO实现
 * @author 王浩羽
 *
 */
public class OccupationChargeItemDaoImpl extends PmsBaseDaoImpl<OccupationChargeItemDO> implements IOccupationChargeItemDao
{

	public Long getIdentityValidateId(Long occupationChargeItemId)
	{
		String queryStr = "select oc.identityValidate.id from OccupationChargeDO oc join oc.chargeItems ot where ot.id = ?";
		Query query = super.createQuery(queryStr, occupationChargeItemId);

		return query.list().size() < 1?null:(Long)query.list().get(0);
	}
	
	/**
	 * 功能描述:查询指定的身份验证下的所有收费项目  <br>
	 * @param identityValidateId 身份验证id
	 * @return
	 *
	 * Create author:付湘辉 <br>
	 * Create on:2009-1-13  <br>
	 * Edit author:  <br>
	 * Edit on:    <br>
	 * Why:     <br>
	 */
	public List<OccupationChargeItemDO> queryItemListByIdentityValidateId(Long identityValidateId) {
		String queryStr = "from OccupationChargeItemDO oc where oc.occupationCharge.identityValidate.id = ?";
		Query query = super.createQuery(queryStr, identityValidateId);

		return query.list();
	}

	public List<OccupationChargeItemDO> queryChargeItemByHouseIdAndStatus(Long houseId, String payStatus)
	{
		String queryStr = "from OccupationChargeItemDO oc where oc.houseId = ? and oc.payState = ? ";
		Query query = super.createQuery(queryStr, houseId, payStatus);
		return query.list();
	}


}
